let obj1 = {
    a: 1,
    b: [2,{e : 1}],
    c: {
        d : 5
    }
}
let obj2 = {
    a: 1,
    b: [2,{e : 1}],
    c: {
        d : 5
    }
}
let obj3 = {
    a: 1,
    b: [2,{e : 2}],
    c: {
        d : 5
    }
}
let obj4 = 1

function twoObjEqualJudge(obj1, obj2) {
    //? 两者的类型都不同 false
    if (Object.prototype.toString.call(obj1) !== Object.prototype.toString.call(obj2)) return false
    //? 两者键长度不同 false
    if (Object.keys(obj1).length !== Object.keys(obj2).length) return false;
    //? 遍历键
    for (let o in obj1) {
        let t1 = obj1[o] instanceof Object;
        let t2 = obj2[o] instanceof Object;
        //? 两者value都是Object 递归
        if (t1 && t2) {
            let res = twoObjEqualJudge(obj1[o],obj2[o])
            //? 递归结果拿到 为false 则 false
            if (!res) return false
        }
        //? 两者value不是Object
        else {
            //? 如果值不同 false
            if (obj1[o] !== obj2[o]) return false
        }
    }
    //? 不返回false就返回true
    return true
}
for(let o in obj4) {
    console.log(o)
}
// console.log(twoObjEqualJudge(obj1, obj2));
// console.log(twoObjEqualJudge(obj1, obj3));
